package com.dianzhihan.cashier.model.product;

import com.dianzhihan.cashier.controller.ErrorRedirectException;
import com.dianzhihan.cashier.model.AbsValidator;

/**
 * @author Dianzhi Han
 * @version 1.0
 * @description: 商品名字合法性校验
 * @date 2023/2/9 11:50
 */
public class NameValidator extends AbsValidator {
    @Override
    public String validate(String productName, String module, String redirectUrl) {
        productName =  super.validate(productName, module, redirectUrl);

        if (productName.length() > 50) {
            throw new ErrorRedirectException("productName的长度超过 50",module,redirectUrl);
        }

        return productName;
    }
}
